.\" Copyright 2018, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
.\" Copyright 2018, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Copyright 2024, Alejandro Colomar <alx@kernel.org>
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH PR_GET_SPECULATION_CTRL 2const 2024-06-01 "Linux man-pages 6.9.1"
.SH NAME
PR_GET_SPECULATION_CTRL
\-
get the state of a speculation misfeature for the calling thread
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/prctl.h>" "  /* Definition of " PR_* " constants */"
.B #include <sys/prctl.h>
.P
.BI "int prctl(PR_GET_SPECULATION_CTRL, long " misfeature ", 0L, 0L, 0L);"
.fi
.SH DESCRIPTION
Return
the state of the speculation misfeature specified in
.IR misfeature .
.P
Currently,
.I misfeature
must be one of:
.TP
.B PR_SPEC_STORE_BYPASS
Get the state of the speculative store bypass misfeature.
.\" commit 9137bb27e60e554dab694eafa4cca241fa3a694f
.TP
.BR PR_SPEC_INDIRECT_BRANCH " (since Linux 4.20)"
Get the state of the indirect branch speculation misfeature.
.P
The return value uses bits 0-4 with the following meaning:
.TP
.B PR_SPEC_PRCTL
Mitigation can be controlled per thread by
.BR PR_SET_SPECULATION_CTRL (2const).
.TP
.B PR_SPEC_ENABLE
The speculation feature is enabled, mitigation is disabled.
.TP
.B PR_SPEC_DISABLE
The speculation feature is disabled, mitigation is enabled.
.TP
.B PR_SPEC_FORCE_DISABLE
Same as
.B PR_SPEC_DISABLE
but cannot be undone.
.TP
.BR PR_SPEC_DISABLE_NOEXEC " (since Linux 5.1)"
Same as
.BR PR_SPEC_DISABLE ,
but the state will be cleared on
.BR execve (2).
.P
If all bits are 0,
then the CPU is not affected by the speculation misfeature.
.P
If
.B PR_SPEC_PRCTL
is set, then per-thread control of the mitigation is available.
If not set,
.BR PR_SET_SPECULATION_CTRL (2const)
for the speculation misfeature will fail.
.SH RETURN VALUE
On success,
.B PR_GET_SPECULATION_CTRL
returns the nonnegative value described above.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B ENODEV
The kernel or CPU does not support the requested speculation
.IR misfeature .
.SH STANDARDS
Linux.
.SH HISTORY
Linux 4.17.
.SH SEE ALSO
.BR prctl (2),
.BR PR_SET_SPECULATION_CTRL (2const)
